[SPARK-20010][SQL] Sort information is lost after sort merge join#17339
Closed
wzhfy wants to merge 1 commit intoapache:masterfrom
Closed
[SPARK-20010][SQL] Sort information is lost after sort merge join#17339wzhfy wants to merge 1 commit intoapache:masterfrom
wzhfy wants to merge 1 commit intoapache:masterfrom
Conversation
Contributor
Author
|
Test build #74770 has started for PR 17339 at commit |
Contributor
Author
|
retest this please |
|
Test build #74783 has finished for PR 17339 at commit
|
Contributor
Author
|
test this please |
Contributor
|
retest this please |
cloud-fan
reviewed
Mar 20, 2017
| child: Expression, | ||
| direction: SortDirection, | ||
| nullOrdering: NullOrdering, | ||
| sameOrderExpressions: Set[Expression]) |
Contributor
There was a problem hiding this comment.
Ideally we don't need this, and we can rely on EqualTo constraint to infer this information. Unfortunately the constraint only exists in logical plan, so we can't find a better solution for this case. cc @gatorsmile do you have a better idea?
|
Test build #74873 has finished for PR 17339 at commit
|
|
Test build #74880 has finished for PR 17339 at commit
|
Contributor
Author
|
retest this please |
|
Test build #74888 has finished for PR 17339 at commit
|
Contributor
|
thanks, merging to master! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
After sort merge join for inner join, now we only keep left key ordering. However, after inner join, right key has the same value and order as left key. So if we need another smj on right key, we will unnecessarily add a sort which causes additional cost.
As a more complicated example, A join B on A.key = B.key join C on B.key = C.key join D on A.key = D.key. We will unnecessarily add a sort on B.key when join {A, B} and C, and add a sort on A.key when join {A, B, C} and D.
To fix this, we need to propagate all sorted information (equivalent expressions) from bottom up through
outputOrderingandSortOrder.How was this patch tested?
Test cases are added.